<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>微信支付</title>
    <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="__PUBLIC__/Css/my.css" rel="stylesheet">

    <script src="__PUBLIC__/Js/my.js"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body style="background-color: #f8f8f8;margin-bottom: 20px;">
<div class="container">
    <include file="Public:top" title="微信支付"/>
    <if condition="$referer eq 'wait'">

    <else/>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" align="center" id="pay-hint"
                 style="background-color:white;padding:10px;color:limegreen;font-size: larger;font-weight: bold;">
                订单已提交!
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 blue-bar">
                <img src="__PUBLIC__/images/info-25.png">
                订单信息
            </div>
        </div>
    </if>

    <include file="Public:orderDetail" status="未支付"/>

    <div class="row" style="margin-top: 20px;" id="pay-nav">
        <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8 col-xs-offset-2 col-sm-offset-2 col-md-offset-2 col-lg-offset-2 pay-bn" align="center" onclick="pay()" style="background-color: #4aaf33;font-size: large;">
            <img src="__PUBLIC__/images/weixin-25.png">
            微信支付
        </div>
    </div>
    <div class="row" id="payed-nav" style="display: none;margin-top: 20px;">
        <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 col-xs-offset-1 col-sm-offset-1 col-md-offset-1 col-lg-offset-1 pay-bn" id="back-home" align="center" onclick="jumpTo('/?m=Home&c=Index&a=index')" style="background-color: #c8c8c8;font-size: large;">
            返回主页
        </div>
        <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 col-xs-offset-2 col-sm-offset-2 col-md-offset-2 col-lg-offset-2 pay-bn" id="to-order" align="center" onclick="jumpTo('/?m=Home&c=Order&a=index')" style="background-color: #ff9900;font-size: large;">
            我的订单
        </div>
    </div>
</div>
<script>
    function onBridgeReady() {
        WeixinJSBridge.invoke(

                'getBrandWCPayRequest', {$jsApiParameters},
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        //alert("支付成功!");
                        //todo 返回到支付成功页面 支付成功页面显示支付成功，并提供两个按钮，分别为返回主页和我的订单
                        $("#pay-hint").html("支付成功!");
                        $("#order-status").html("支付成功");
                        $("#pay-nav").css("display","none");
                        $("#payed-nav").css("display","");
                    }
                }
        );
    }
    /**
     * 支付方法
     */
    function pay() {
        if (typeof WeixinJSBridge == "undefined") {
            alert("请使用微信浏览器支付");
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    }

    function home(){
        window.location.href="{:U('Index/index')}"
    }
    function order(){
        window.location.href="{:U('Order/index')}";
    }
</script>
</body>
</html>